package leetcode.code1668;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution3 implements IDebug {

	public int maxRepeating(String sequence, String word) {
		int ans = 0;
		char[] cs = sequence.toCharArray();
		char[] ws = word.toCharArray();
		int p = 0;
		while (p < cs.length) {
			if (cs[p] == ws[0]) {
				int k = 0, t = p, i = 0;
				while (t < cs.length && cs[t] == ws[i]) {
					t++;
					if (i + 1 < ws.length) {
						i += 1;
					} else {
						i = 0;
						k++;
					}
				}
				ans = Math.max(ans, k);
			}
			p++;
		}
		return ans;
	}

	@Override
	public void debug4() {
		HelpDebug.compare(5, this.maxRepeating("aaabaaaabaaabaaaabaaaabaaaabaaaaba", "aaaba"));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution3 so = new Solution3();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
